#include "app.h"

#define BTN_HEIGHT  50
#define BTN_WIDTH   50

void btn_back_event_default_cb(lv_obj_t * btn, lv_event_t event)
{
    if(event == LV_EVENT_CLICKED) {
        lv_obj_t * par = lv_obj_get_parent(btn);
        lv_obj_del(par);
         
        lv_label_set_text(label_menu,"MENU");
        lv_obj_align(label_menu,scr_tft,LV_ALIGN_CENTER, 0 ,0);

        eink_scene_ready=false;
        eink_flash_ready=false;
    }
}



lv_obj_t *btn_back_create(lv_obj_t *par, lv_event_cb_t event_cb)
{

    lv_obj_t *btn = lv_btn_create(par,NULL);

    lv_obj_set_size(btn,BTN_WIDTH,BTN_HEIGHT);
    lv_obj_align(btn,par,LV_ALIGN_IN_BOTTOM_LEFT,0,0);
    lv_obj_set_event_cb(btn,event_cb);

    static lv_style_t style_btn;
    lv_style_copy(&style_btn,&lv_style_transp);
    lv_btn_set_style(btn,LV_BTN_STYLE_REL,&style_btn);


    lv_obj_t *label = lv_label_create(btn,NULL);
    lv_label_set_text(label,LV_SYMBOL_CLOSE);
    lv_obj_align(label,btn,LV_ALIGN_CENTER,0,0);
    
    

    return btn;
}

lv_obj_t *page_create(lv_obj_t *par)
{
    lv_obj_t *cont = lv_cont_create(par,NULL);
    lv_obj_set_size(cont,lv_disp_get_hor_res(lv_eink),lv_disp_get_ver_res(lv_eink)-BTN_HEIGHT);
    lv_obj_align(cont,par,LV_ALIGN_IN_TOP_MID,0,0);


    return cont;
}

